<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增广告位素材')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-adMaterial-add">
        <input id="adId" name="adId" class="form-control" th:value="${adId}" type="hidden">

        <div class="form-group">
            <label class="col-sm-3 control-label">广告素材：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input id="materialId" name="materialId" class="form-control" required type="hidden">
                    <input id="materialName" class="form-control valid" type="text" onclick="selectImage()" required   readonly="true"  aria-invalid="false">
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">链接：</label>
            <div class="col-sm-8">
                <input  name="link" class="form-control"  type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">排序：</label>
            <div class="col-sm-8">
                <input  name="sort" class="form-control" value="255" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">起止时间：</label>
            <div class="col-sm-8">
                <div class="input-daterange input-group">
                    <input type="text"  class="form-control time-input" id="startTime" placeholder="开始时间" name="startTime"/>
                    <span class="input-group-addon">-</span>
                    <input type="text" class="form-control time-input" id="endTime" placeholder="结束时间" name="endTime"/>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">有效状态：</label>
            <div class="col-sm-8">
                <label class="toggle-switch switch-solid">
                    <input id="status" name="status" class="form-control" value="0" type="hidden">
                    <input type="checkbox" id="isAvailable"  checked>
                    <span></span>
                </label>
            </div>
        </div>


    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "cms/ad"
    $("#form-adMaterial-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/addAdMaterialSave", $('#form-adMaterial-add').serialize());
        }
    }
    $(function(){
        $("#isAvailable").on("change",function(){
            var v=$(this).prop("checked");
            if(v){
                $("#status").val("0");//有效
            }else{
                $("#status").val("1");
            }
        });
    })
    function selectImage() {
        var url=ctx+"cms/ad/selectAdMaterial/"+$("#adId").val();
        $.modal.open("广告素材选择",url);
    }

</script>
</body>
</html>